package com.chainshop.inboundRecords.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chainshop.common.annotation.Log;
import com.chainshop.common.core.controller.BaseController;
import com.chainshop.common.core.domain.AjaxResult;
import com.chainshop.common.enums.BusinessType;
import com.chainshop.inboundRecords.domain.InboundRecords;
import com.chainshop.inboundRecords.service.IInboundRecordsService;
import com.chainshop.common.utils.poi.ExcelUtil;
import com.chainshop.common.core.page.TableDataInfo;

/**
 * 入库记录Controller
 * 
 * @author zzd
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/inboundRecords/inboundRecords")
public class InboundRecordsController extends BaseController
{
    @Autowired
    private IInboundRecordsService inboundRecordsService;

    /**
     * 查询入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(InboundRecords inboundRecords)
    {
        startPage();
        List<InboundRecords> list = inboundRecordsService.selectInboundRecordsList(inboundRecords);
        return getDataTable(list);
    }

    /**
     * 导出入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:export')")
    @Log(title = "入库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InboundRecords inboundRecords)
    {
        List<InboundRecords> list = inboundRecordsService.selectInboundRecordsList(inboundRecords);
        ExcelUtil<InboundRecords> util = new ExcelUtil<InboundRecords>(InboundRecords.class);
        util.exportExcel(response, list, "入库记录数据");
    }

    /**
     * 获取入库记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(inboundRecordsService.selectInboundRecordsById(id));
    }

    /**
     * 新增入库记录
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:add')")
    @Log(title = "入库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InboundRecords inboundRecords)
    {
        return toAjax(inboundRecordsService.insertInboundRecords(inboundRecords));
    }

    /**
     * 修改入库记录
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:edit')")
    @Log(title = "入库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InboundRecords inboundRecords)
    {
        return toAjax(inboundRecordsService.updateInboundRecords(inboundRecords));
    }

    /**
     * 删除入库记录
     */
    @PreAuthorize("@ss.hasPermi('inboundRecords:inboundRecords:remove')")
    @Log(title = "入库记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(inboundRecordsService.deleteInboundRecordsByIds(ids));
    }
}
